package router

import (
	"github.com/gin-gonic/gin"
	"github.com/mjcode-max/TurboGin/internal/controller"
	"github.com/mjcode-max/TurboGin/pkg/middleware"
)

func RegisterRoutes(ctl *controller.Container, auth *middleware.Auth) func(*gin.Engine) {

	return func(engine *gin.Engine) {
		// *** 测试路由 ***
		engine.GET("/ping", func(c *gin.Context) {
			c.JSON(200, gin.H{"message": "pong"})
		})

		engine.POST("/ping1", func(c *gin.Context) {
			c.JSON(200, gin.H{"message": "pong1"})
		})

		// ==================== 公共路由 ====================
		publicGroup := engine.Group("/v1")
		{
			publicGroup.POST("/register", ctl.User.CreateUser)
		}

		// ==================== 受保护路由 ====================
		privateGroup := engine.Group("/v1")
		privateGroup.Use(auth.Middleware())
		{
			userRoutes := privateGroup.Group("/users")
			{
				userRoutes.GET("/:id", ctl.User.GetUser)
			}
		}

		// *** 排行榜 ***
		rankRoutes := engine.Group("/rank")
		rankController := controller.NewRankController()
		{
			rankRoutes.GET("/province", rankController.GetRank)
			rankRoutes.GET("/skins", rankController.GetSkinsRank)
		}

	}
}
